package com.asiainfo.javalcass;

import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.IOException;

public class ClassParseReader {

	public ClassParseReader(String classPath) {
		FileInputStream fs = null;
		try {
			fs = new FileInputStream(classPath);
			ByteArrayOutputStream out = new ByteArrayOutputStream();
			byte[] buf = new byte[1024];
			int actual;
			do {
				actual = fs.read(buf);
				if (actual > 0) {
					out.write(buf, 0, actual);
				}
			} while (actual > 0);
			JavaClassReader reader = new JavaClassReader(out.toByteArray());
			reader.parseClassFile();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (fs != null)
				try {
					fs.close();
				} catch (IOException e) {

					e.printStackTrace();
				}
		}

	}
}
